#include "ImportFrom.h"
#include "IVisitor.h"

ImportFrom::ImportFrom(const NameTokPtr& module, const AliasTypeList& names, int level, int nodeId):
    stmtType(nodeId),
    _module(module),
    _names(names),
    _level(level)
{
}
    
ImportFrom::~ImportFrom()
{
    _names.clear();
}
    
QString ImportFrom::type() const
{
    return "ImportFrom";
}
    

NameTokPtr ImportFrom::module()
{
    return _module;
}

void ImportFrom::setModule(const NameTokPtr& module)
{
    _module = module;
}

AliasTypeList ImportFrom::names()
{
    return _names;
}

void ImportFrom::setNames(const AliasTypeList& names)
{
    _names = names;
}

int ImportFrom::level()
{
    return _level;
}

void ImportFrom::setLevel(int level)
{
    _level = level;
}

    
QString ImportFrom::toString() const
{
    return QString("ImportFrom[module=%1, names=%2, level=%3]").
                arg(_module ? _module->toString():"").
                arg(_names.toString()).
                arg(_level);
}
    
void ImportFrom::accept(IVisitor* visitor, const SimpleNodePtr& node)
{
    visitor->visitImportFrom(node.dynamicCast<ImportFrom>());
}
    
void ImportFrom::traverse(IVisitor* visitor)
{
    if (_module != NULL)
        _module->accept(visitor, _module);
    _names.traverse(visitor);
}